import type { AddressItemType, AddressParamsType } from '@/types/address'
import { http } from '@/utils/http'

/**
 * 添加收货地址
 * @returns 
 */
export const addAddressHttp = (data:AddressParamsType)=>{
  return http({
    url:'/member/address',
    method:'POST',
    data,
  })
}

/**
 * 地址列表
 */
export const getAddressListHttp = ()=>{
  return http<AddressItemType[]>({
    url:'/member/address',
    method:'GET'
  })
}

/**
 * 获取收货地址详情
 * @param id 地址的id
 * @returns 
 */
export const getAddressDetailHttp = (id:string)=>{
  return http<AddressItemType>({
    url:'/member/address/'+ id,
    method:'GET'
  })
}
/**
 * 修改收货地址
 * @param id 地址的id
 * @returns 
 */
export const updateAddressHttp = (id:string,data:AddressParamsType)=>{
  return http({
    url:`/member/address/${id}`,
    method:'PUT',
    data,
  })
}

/**
 * 删除收货地址
 * @param id 地址的id
 * @returns 
 */
export const deleteAddressHttp = (id:string)=>{
  return http({
    url:`/member/address/${id}`,
    method:'DELETE',
  })
}
